function HandleTemplate(gui, user, date, options, message) {
  this._gui = gui;
  this._user = user;
  this._date = date;
  this._options = options;
  this._message = message;
  
  this._createElements();
};

HandleTemplate.prototype._createElements = function() {
  MClientUtils.countIt(new RequestUtils());
  
  //Preset
  //Object
  var template = (this._message[0] && this._message[0].data[0]) ? this._message[0].data[0] : pz_template.instance();
  if (!template.id && template.type == '') {
    template.type = types[0];
  }
  
  this._gui.nav.style.display = 'table';
  
  var tr, td;
  tr = this._gui.nav.insertRow(-1);
  td = tr.insertCell(-1);
  td.style.cursor = 'pointer';
  td.style.width = '31px';
  var img = document.createElement('img');
  img.src = 'image/nav/home.png';
  td.onclick = function() { location.href = '?t=clients'; };
  td.appendChild(img);
  
  td.style.padding = '0 0 0 10px';
  td = tr.insertCell(-1);
  td.style.padding = '1px 0 0 0';
  td.style.width = '20px';
  var img = document.createElement('img');
  img.src = 'image/nav/split.png';
  td.appendChild(img);
  
  td = tr.insertCell(-1);
  td.style.cursor = 'pointer';
  td.style.width = '100px';
  td.style.fontWeight = 'bold';
  td.onclick = function() { location.href = '?t=templates'; };
  td.appendChild(document.createTextNode('All Templates'));
  
  td = tr.insertCell(-1);
  td.style.padding = '1px 0 0 0';
  td.style.width = '20px';
  var img = document.createElement('img');
  img.src = 'image/nav/split.png';
  td.appendChild(img);
  
  td = tr.insertCell(-1);
  td.appendChild(document.createTextNode((template.id) ? 'Template ' + template.name : 'New Template'));

  td = tr.insertCell(-1);
  td.style.textAlign = 'right';
  td.style.cursor = 'pointer';
  td.style.padding = '0 5px 0 0';
  td.style.width = '40px';
  td.style.borderLeft = 'solid 1px #c0c0c0';
  var img = document.createElement('img');
  img.src = 'image/nav/back.png';
  td.onclick = function() { history.back(); };
  td.appendChild(img);
  //Display
  this._gui.name.value = template.name;
  this._gui.content.value = template.content;
  //Event
  this._gui.name.onchange = function() { template.name = this.value; };
  this._gui.content.onchange = function() { template.content = this.value; };
  //Submit
  this._gui.save.onclick = function() { new RequestUtils()._write(JSON.stringify([{ n: 'pz_template', a: [template], r: [] }]), function(result, params) { location.href = '?t=templates'; }, { pos: DOMUtils.findPos(this) });
                                      };
};
